/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.com.sixboy.controller;

import cn.com.sixboy.cache.Cache;
import cn.com.sixboy.cache.Property;
import cn.com.sixboy.cache.WebConfig;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 *
 * @author sam.zheng <zcl1866@sina.com> 
 * @version <v0.1>
 * @date  2013-06-03 09:25:16
 * @copyright <sixboy>
 */
@Controller
@RequestMapping("/tpl")
public class AppStyleController {
    
    Logger log4j =  Logger.getLogger(AppStyleController.class);
    private WebConfig.AppStyleInfo appStyleInfo  = null;
    @PostConstruct
    public void init(){
        WebConfig config = Cache.getInstance().getConfig();
        appStyleInfo = config.getAppStyleInfo();
    }
    @RequestMapping(value="/header",method= RequestMethod.GET)
    public String hearder(HttpServletResponse response,HttpServletRequest request){
        try {
            String path = Property.TPL_PATH+"/"+appStyleInfo.getAppStyle()+"/"+appStyleInfo.getHeader();
            request.getRequestDispatcher(path).forward(request, response);
        } catch (Exception ex) {
          log4j.error(ex);
        }
        return null;
    }
    @RequestMapping(value="/footer",method= RequestMethod.GET)
    public String footer(HttpServletResponse response,HttpServletRequest request){
        try {
            String path = Property.TPL_PATH+"/"+appStyleInfo.getAppStyle()+"/"+appStyleInfo.getFooter();
            request.getRequestDispatcher(path).forward(request, response);
        } catch (Exception ex) {
          log4j.error(ex);
        }
        return null;
    }
}
